from django import forms
from . models import Comment

class EmailPostForm(forms.Form):
    name = forms.CharField(max_length=25)  #names CharField 被渲染成<input type="text">HTML元素
    email = forms.EmailField()
    to = forms.EmailField()
    comments = forms.CharField(required=False, widget=forms.Textarea)  #渲染成<textarea></textarea>;requirst=False让comments的字段可选


class CommentForm(forms.ModelForm):
    #在Meta中申明使用的model来构建表单
    class Meta:
        model = Comment
        #使用 fields 来确定表单中使用的字段，或使用exclude来排除不用的字段
        fields = ('name', 'email', 'body')
